//---------------------------------------------------------------------------------
// Copyright (c) 2011, Microsoft Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//---------------------------------------------------------------------------------

namespace Microsoft.ServiceBus.Samples
{
    using System;
    using System.Management.Automation;

    [Cmdlet("Set", "ServiceBusCredentials")]
    public class SetServiceBusCredentialsCmdlet : PSCmdlet
    {
        public SetServiceBusCredentialsCmdlet()
        {
            this.IssuerName = "owner";
        }

        [Parameter(
        Mandatory = false,
        HelpMessage = "ACS IssuerName")]
        public string IssuerName
        {
            get;
            set;
        }

        [Parameter(
        Mandatory = true,
        HelpMessage = "ACS IssuerSecret")]
        public string IssuerSecret
        {
            get;
            set;
        }

        [Parameter(
        Mandatory = true,
        HelpMessage = "ServiceBus namespace")]
        public string Namespace
        {
            get;
            set;
        }

        protected override void ProcessRecord()
        {
            this.SessionState.PSVariable.Set(new PSVariable("IssuerName", this.IssuerName));
            this.SessionState.PSVariable.Set(new PSVariable("IssuerSecret", this.IssuerSecret));
            this.SessionState.PSVariable.Set(new PSVariable("Namespace", this.Namespace));

            WriteVerbose(string.Format("Set IssuerName {0} ", this.IssuerName));
            WriteVerbose(string.Format("Set IssuerSecret {0} ", this.IssuerSecret));
            WriteVerbose(string.Format("Set Namespace {0} ", this.Namespace));

            Context.ClearContext();
        }
    }
}
